package com.javabasic.generic;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @Author xiongmin
 * @Description
 * @Date 2021-06-08 11:32
 * @Version 1.0
 **/
public class GenericTest {


    public static void main(String[] args) {
        String str = "nihao";
        ArrayList<String> list = new ArrayList<>();
        list.add(str);
        showSomething(list);
        showSomething2(list);
    }

    /**
     * 感觉泛型通配符？ 应用在方法上和Object的作用差不多
     * @param collection
     */
    public static void showSomething(Collection<?> collection) {
        for (Object o : collection) {
            System.out.println(o.toString());
        }
    }

    public static <T> void showSomething2(Collection<T> collection) {
        for (Object o : collection) {
            System.out.println(o.toString());
        }
    }
}
